<template>
	<view class="information-list">
		<uni-swipe-action v-if="list && list.length > 0">
			<uni-swipe-action-item  v-for="(item,index) in list" :key="index" @click="bindClick(item)">
				<view class="item"  @click="toView(item)">
					<div class="item-l">
						<image mode="aspectFill" :src="!item.status || item.status == 1 ?'../../../static/img/monitor/not-archived.png':'../../../static/img/monitor/archived.png'"></image>
						<text>{{item.operatorName}}</text>
					</div>
					<div class="item-c">
						<p>干预方案</p>
						<p>方案编号：{{!item.status || item.status == 1?'未存档':item.schemeNumber}}</p>
						<p>{{!item.status || item.status == 1?'存档时间：未存档':'签发时间：'+item.updateTime}}</p>
					</div>
					<div :class="['item-r',!item.status || item.status == 1?'not-archived':'archived']">{{!item.status || item.status == 1?'未存档':'已存档'}}</div>
				</view>
			</uni-swipe-action-item>
		</uni-swipe-action>
		<view class="nulldata" style="text-align: center;font-size: 26upx;color: #ccc;padding: 20upx 0;" v-if="nullData && list && list.length > 0">
			<view>没有更多数据了</view>
		</view>
		<view class="noneChating" v-if="!list || list && list.length <=0">
			<image src="../../../static/img/index/chattingNone.png"></image>
			<view>暂无数据</view>
		</view>
	</view>
	
</template>

<script>
import {filterData2} from '@/static/js/filter.js';
import uSwipeActionItem from "@/components/uni-swipe-action-item/uni-swipe-action-item.vue";
import uniSwipeAction from "@/components/uni-swipe-action/uni-swipe-action.vue";
export default{
	data(){
		return {
			pageIndex: 1,
			pageSize: 10,
			list: null,
			page:1,
			deleteList:'',
			nullData: false,
		}
	},
	onLoad(){
		this.getlist({pageIndex:this.pageIndex,pageSize:this.pageSize})
	},
	onReachBottom() {
		if(this.nullData == true){
			return;
		}
		this.page = this.page + 1
		this.getlist({pageIndex:this.page,pageSize:this.pageSize})
	},
	methods:{
		filterData2,
		getlist(data){
			this.$api.interveneSchemeList(data).then((res)=>{
				var data = res.data.result && res.data.result.list.map((a)=> {
					a.updateTime = this.filterData2(a.updateTime);
					return a
				});
				if(this.deleteList == 1) {
					this.list = []
					this.list = data
					this.deleteList = ''
				}else {
					this.list = this.list ? this.list.concat(data) : data
				}
				if(this.list.length >= res.data.result.totalCount){
					this.nullData = true;
				}
			})
		},
		toView(e) {
			uni.navigateTo({
				url:'/pages/monitor/intervention/toView?id='+e.id
			})
		},
		bindClick(e) {
			const id = e.id;
			this.$api.UserinforDeleteId(id).then((res) => {
				if(res.data.returnCode == '200') {
					uni.showToast({
						title: '删除成功',
						icon: 'none'
					})
					this.page = 1
					this.deleteList = 1;
					this.nullData = false;
					this.getlist({pageIndex:this.pageIndex,pageSize:this.pageSize})
				}
			})
		}
	}
}
</script>

<style lang="scss" scoped>
	.information-list{
		min-height: calc(100vh - 88upx);
		background: #F8F8F8;
		.item{
			display: flex;
			padding: 42upx 21upx;
			background: #fff;
			margin-bottom: 24upx;
			width: 100%;
			&-l{
				position: relative;
				image{
					width: 92upx;
					height: 106upx;
					margin-right: 48upx;
					margin-top: 10upx;
				}
				text {
					width: 92upx;
					position: absolute;
					bottom: 20upx;
					color: #FFFFFF;
					font-size: 24upx;
					left: 0;
					overflow: hidden;    
					text-overflow:ellipsis;    
					white-space: nowrap;
					display: block;
					text-align: center;
				}
			}
			&-c{
				flex:1;
				font-size: 28upx;
				line-height: 1.5;
				&:nth-of-type(1){
					font-weight: bold;
					font-size: 30upx;
				}
			}
			&-r{
				font-size: 26upx;
				&.not-archived{
					color: #1A85E9;
				}
				&.archived{
					color: #38CB97;
				}
			}
		}
		.noneChating {
			padding-top: 228upx;
			image {
				display: block;
				margin: 0 auto;
				width: 260upx;
				height: 154upx;
			}
			view {
				margin: 24px auto;
				text-align: center;
				color: #333333;
				font-size: 13px;
			}
		}
	}
</style>
